var ctx ="";
//获取上下文路径
function getContextPath() {
	var pathName = document.location.pathname;
	var index = pathName.substr(1).indexOf("/");
	var result = pathName.substr(0, index + 1);
	ctx = result;
	return result;
}
/**
 * 获取url路径中的参数
 * name:url参数名称
 * result:参数值
 **/
function getRequestParm(name){
	//获取url中"?"符后的字串
	var url = location.search; 
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for(var i = 0; i < strs.length; i ++) {
		theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
		}
	}
	var result = theRequest[name];
	if(result == "undefined"){
		result = "";
	}
	return result;
}


/**
 * 该函数仅用于单点登录
 * 获取url路径中的参数
 * name:url参数名称
 * result:参数值
 **/
function getRequestParm_dddl(name){
	//获取url中"?"符后的字串
	var url = location.search; 
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(10);
		result = str;
	}
	
	return result;
}

function GetQueryString(name) 
{ 
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
var r = window.location.search.substr(1).match(reg); 
if (r!=null) return unescape(r[2]); return null; 
}  
	
/**
 * 获取当前时间 yyyy-mm-dd HH:MM:ss
 * @returns {String}
 */
function currentTime(){
    var date = new Date();
    var y = date.getFullYear();
    var m = date.getMonth()+1;
    var d = date.getDate();
    var h = date.getHours();
    var i = date.getMinutes();
    var s = date.getSeconds();
    return y+"-"+(m>9?m:("0"+m))+"-"+(d>9?d:("0"+d))+" "+(h>9?h:("0"+h))+":"+(i>9?i:("0"+i))+":"+(s>9?s:("0"+s));
  }


/**
 * 获取当前时间
 * @returns {String}yyyy-mm-dd
 */
function currentDate(){
    var date = new Date();
    var y = date.getFullYear();
    var m = date.getMonth()+1;
    var d = date.getDate();
    return y+"-"+(m>9?m:("0"+m))+"-"+(d>9?d:("0"+d));
  }